|
|
 |
|
|
|
|
.Left = 0
.Caption = "With...End With Example"
.WindowState = vbMaximized
.Show
End With
End Sub |
|
|
|
|
|
|
|
|
As you can see, this code is much more readable than the first version. It also saves the amount of typing you have to do. Whats more, a better benefit is that this is more efficient than specifying the same object name over and over again. |
|
|
|
|
|
|
|
|
This chapter showed you how to use the different decision structures and looping constructs available in the Visual Basic language. If statements and Select Case statements allow your program to make decisions as to which code to run. Do loops and For...Next loops allow you to iterate over many statements a specified amount of time or until some condition becomes true. |
|
|
|
|
|
|
|
|
Review Questions/Exercises |
|
|
|
|
|
|
|
|
1. Write an If statement that checks to see whether one number is greater than another, and if it is, displays a message box saying Number 1 is greater than Number 2. |
|
|
|
|
|
|
|
|
2. Write a Do...Loop that loops from 10 to 1. Print each value on the form. |
|
|
|
|
|
|
|
|
3. Write a For...Nextloop that loops from 1 to 100 and only prints the value 50 when the loop variable becomes 50. |
|
|
|
|
|